package org.hao.samples.test;

import java.util.Date;
import java.util.List;

import org.hao.samples.dao.IExamScoreDAO;
import org.hao.samples.model.ExamScore;
import org.hao.samples.model.Subject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "file:WebContent/WEB-INF/viewspace-servlet.xml" })
public class testScore {
	@Autowired
	private IExamScoreDAO dao;

	@Test
	public void test() {
		List<ExamScore> list = dao.findExamScoreBystuIdAndsubId(2015232, 1);
		for (ExamScore l : list) {
			System.out.println("题目：" + l.getId() + l.getSubject().getName());
		}
	}

	@Test
	public void test1() {
		ExamScore l = dao.findExamScoreById(90);
		System.out.println("题目：" + l.getExamTime() + l.getScore());
	}
	
	@Test
	public void test2(){
		ExamScore test = new ExamScore();
		Subject subject = new Subject();
		subject.setSub_id(1);
		
		test.setExamTime(new Date());
		test.setSubject(subject);
		test.setUserId(2015222);
		test.setTestId("45,85,88,");
		dao.addExamScore(test);
	}
	
	@Test
	public void test3(){
		ExamScore exam = dao.findExamScoreBystuIdAndsubId(2015232, 1).get(0);
		System.out.println(exam.getScore());
	}
}
